<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增盘点')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form id="formId">
            <input name="companyId" type="hidden" id="companyId"/>
            <input name="flag" type="hidden" value="1"/>
            <div class="select-list">
                <ul>
                    <!--<li>-->
                        <!--<p>盘点单号：</p>-->
                        <!--<input type="text" name="oddNumber" th:value="*{oddNumber}"/>-->
                    <!--</li>-->
                    <li>
                        <p>所属组织：</p>
                        <input name="companyName" onclick="selectCompanyTree()" id="companyName" type="text">
                    </li>
                    <!--<li>-->
                        <!--<p>开始时间：</p>-->
                        <!--<input type="text" class="time-input" id="startTime"  name="startDate"/>-->
                    <!--</li>-->
                    <!--<li>-->
                        <!--<p>结束时间：</p>-->
                        <!--<input type="text" class="time-input" id="endTime" name="endDate"/>-->
                    <!--</li>-->
                    <li>
                        <p>资产类别：</p>
                        <select name="assetType" class="form-control select2-multiple" th:with="type=${@dict.getType('asset_type')}">
                            <option value="">不限</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <p>资产情况：</p>
                        <select name="useStatus" class="form-control select2-multiple" th:with="type=${@dict.getType('use_status')}">
                            <option value="">不限</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        <!--<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                    </li>
                </ul>
            </div>
        </form>
    </div>
    <div class="btn-group-sm" id="toolbar" role="group">
    </div>
    <div class="col-sm-12 select-table table-striped">
        <table id="bootstrap-table"></table>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "inventory/inventory"
        $("#form-inventory-add").validate({
            focusCleanup: true
        });

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        //选择公司树
        function selectCompanyTree() {
            var deptId = $.common.isEmpty($("#companyId").val()) ? "100" : $("#companyId").val();
            var url = ctx + "system/dept/selectCompanyTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmitCompany
            };
            $.modal.openOptions(options);
        }
        function doSubmitCompany(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#companyId").val(body.find('#treeId').val());
                $("#companyName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }
        $(function () {
            var options = {
                url:ctx + "asset/assetDetail/list",
                sortName: "createTime",
                sortOrder: "desc",
                modalName: "资产信息",
                columns: [
                    {
                        field : 'assetCode',
                        title : '资产编码'
                    },
                    {
                        field : 'assetName',
                        title : '资产名称'
                    },
                    {
                        field : 'specifications',
                        title : '规格'
                    },
                    {
                        field : 'assetModel',
                        title : '型号'
                    },
                    {
                        field : 'companyName',
                        title : '所属组织'
                    },
                    {
                        title: '操作',
                        align: 'left',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="inventory(\'' + row.id + '\')"><i class="fa fa-edit"></i>添加</a> ');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        })
        function inventory(id) {
            $.modal.open("添加确认",prefix + "/editAsset/"+id);
        }
        function submitHandler() {
            $.modal.close(layer.index);
            parent.$.table.refresh();
        }
    </script>
</body>
</html>